package com.resume.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.resume.constant.GlobalConst;
import com.resume.domain.XueLi;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

import com.resume.domain.Province;
import com.resume.mapper.ProvinceMapper;
import com.resume.service.ProvinceService;

/**
 * @Author: 梁云亮
 * @Date: 2021/7/16 11:59
 * @Describe:
 */
@Service
public class ProvinceServiceImpl extends ServiceImpl<ProvinceMapper, Province> implements ProvinceService {

    @Override
    public List<Province> listAllUsableProvince() {
        QueryWrapper<Province> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "name", "area")
                .eq("status", GlobalConst.Common.STATUS_ENABLE)// 1 表示显示
                .orderByAsc("priority");
        List<Province> provinceList = baseMapper.selectList(queryWrapper);
        return provinceList;
    }

    @Override
    public boolean modifyProvinceStatus(Integer id, int status) {
        Province province = Province.builder()
                .id(id)
                .status(status)
                .build();
        int res = baseMapper.updateById(province);
        return res == 1 ? true : false;
    }

    @Override
    public boolean modify(Province province) {
        QueryWrapper<Province> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", province.getId());
        int updateRes = baseMapper.update(province, queryWrapper);
        return updateRes == 1 ? true : false;
    }
}
